package com.ruoyi.framework.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;

import java.io.IOException;

/**
 * @program: test_demo
 * @description: RedissonConfig配置类读取yml的配置信息
 * @author: yanghua
 * @create: 2021-09-24 11:34
 **/
@Configuration
public class RedssonConfig {
    @Bean(destroyMethod = "shutdown")
    public RedissonClient redisson() throws IOException
    {
        RedissonClient redisson = Redisson.create(Config.fromYAML(new ClassPathResource("redisson-single.yml").getInputStream()));
        System.out.println("redisson : "+redisson);
        return redisson;
    }
}
